/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

var respRsjObj = null;
var respYsjObj = null;
/*电压等级转换成相应的电压值*/
function voltageLevel2Value(level) {
    if (level === '0.22KV') {
        return 1;
    }
    else if (level === '0.38KV') {
        return 1;
    } else if (level === '6KV') {
        return 60;
    } else if (level.startsWith('10KV')) {
        return 100;
    }else if (level.startsWith('20K')) {
        return 200;
    } else if (level.startsWith('35KV')) {
        return 350;
    } else if (level.startsWith('66K')) {
        return 660;
    } else if (level.startsWith('110K')) {
        return 1100;
    }else if (level.startsWith('220K')) {
        return 2200;
    }else if (level.startsWith('330K')) {
        return 3300;
    }else if (level.startsWith('500K')) {
        return 5000;
    }else if (level.startsWith('750K')) {
        return 750;
    }    else {
        return 1;
    }
}
/*将设备召回的数据转换成较易读的格式*/
function toReadableStr(respObj) {
    var resultStr = '';
    resultStr += respObj.YEAR + '年' + respObj.Month + '月';
    if (respObj.Date != null && respObj.Date != '') {
        resultStr += respObj.Date + '日 ';
    }
    resultStr += ' 总运行时:' + respObj.ZYXS;
    resultStr += ' 超上限时:' + respObj.CSXS;
    resultStr += ' 超下限时:' + respObj.CXXS;
    resultStr += ' 最大值:' + respObj.ZDZ;
    resultStr += ' 最大值时:' + respObj.ZDZS.substring(0, 2) + '-'
            + respObj.ZDZS.substring(2, 4) + ' ' + respObj.ZDZS.substring(4, 6)
            + ':' + respObj.ZDZS.substring(6, 8);
    resultStr += ' 最小值:' + respObj.ZXZ;
    resultStr += ' 最小值时:' + respObj.ZXZS.substring(0, 2) + '-'
            + respObj.ZXZS.substring(2, 4) + ' ' + respObj.ZXZS.substring(4, 6)
            + ':' + respObj.ZXZS.substring(6, 8);
    resultStr += ' 平均值:' + respObj.PJZ;
    return resultStr;
}
/*将时间11201010转化成 2019-11-20 10:10:00.0 yyyy-MM-dd hh:mm:ss.f格式*/
function toTimestamp(year,time){
    var timeStr=year+"-"+time.substring(0, 2) + '-'
            + time.substring(2, 4) + ' ' + time.substring(4, 6)+":"
            + time.substring(6, 8)+':00.0';
    return timeStr;
}
Ext.QuickTips.init();
var _pageSize = 20;
var _pageSizeSmall = 10;
var fieldName = ['id', 'name', 'x', 'y', 'h', 'pointTypeId', 'pointType', 'pointType2Id', 'pointType2', 'voltageLevelId', 'voltageLevelName', 'status', 'note', 'updateTime',
    'creatTime', 'orgCode', 'deptId', 'fromId', 'lowerLimit', 'upperLimit', 'pointArea', 'pointPosition', 'userName', 'publicName', 'deviceId', 'code', 'mobileNo', 'channel',
    'terminalNo', 'port', 'uniqueCode', 'checkTime', 'produceTime', 'manufactoryName', 'adminAreaCode', 'zbm', 'thdLimit', 'baudRate', 'heartRate', 'userName', 'gprsPassWord',
    'ip', 'port', 'serviceIp', 'servicePort', 'mask', 'gatewayIp', 'Apn', 'DnsIp', 'commTypeName', 'countDate', 'ratio', 'model', 'startStatusCh'];
var fieldLabel = ['ID', '监测点名称', '经度', '纬度', '高度', '监测点类型ID（类别1）', '监测点类型(类别1)', '电网类型ID（类别2）', '电网类别（类别2）', '电压等级ID', '电压等级',
    '状态', '备注', '记录的更新时间', '记录的创建时间', '机构编码', '所属部门编码', '上级监测点', '电压下限', '电压上限', '用户名称', '公变名称', '设备ID', '监测点编码', '通信卡号',
    '通道', '终端地址', '端口', '唯一码', '检验日期', '生产日期', '生产厂家', '行政区域码', '组编码', 'THD限值', '波特率', '心跳', 'GPRS用户', 'GPRS密码', '终端IP', '终端端口',
    '服务器IP', '服务器端口', '子掩码', '网关IP', 'APN', 'DNSIP', '通信方式', '统计起始日', '倍率'];

var loadServlet = '../../../servlet/system/PointLoad';
var paramsSetServlet = '../../../servlet/point/ParamsSet';

var theme = '参数';
var _title = currentOrgName + theme + '管理';
var now = new Date();

var voltageLevelStoreF = new Ext.data.JsonStore({
    url: '../../../servlet/common/SimpleFormInfoLoad',
    baseParams: {id: 'id', name: 'name,lowerLimit,upperLimit', tableName: 't_voltageLevel'},
    autoLoad: true,
    root: 'data',
    fields: ['id', 'name', 'lowerLimit', 'upperLimit']
});

var voltageLevelComboF = {
    xtype: 'combo',
    store: voltageLevelStoreF,
    id: 'voltageLevelName',
    name: 'voltageLevelName',
    displayField: 'name',
    valueField: 'id',
    hiddenName: 'voltageLevelId',
    mode: 'remote',
    forceSelection: true,
    allowBlank: false,
    blankText: '不允许为空',
    triggerAction: 'all',
    fieldLabel: '电压等级',
    width: 180,
    selectOnFocus: true,
    listeners: {
        select: function(combo, record, index) {
            //alert(record.get('lowerLimit'));
            //alert(record.get('UpperLimit'));
            Ext.getCmp('LowerLimit').setValue(record.get('lowerLimit'));
            Ext.getCmp('UpperLimit').setValue(record.get('upperLimit'));
        }
    }
};

var param1 = "";
var param2 = "";

var basic11 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '监测点名称',
            name: 'name',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '行政区域码',
            id: 'AdminAreaCode',
            name: 'adminAreaCode',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '组编码',
            id: 'Zbm',
            name: 'zbm',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '终端地址',
            id: 'TerminalNo',
            name: 'terminalNo',
            anchor: '95%'
        }
    ]
};

var basic12 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        voltageLevelComboF,
        {
            name: 'lowerLimit',
            id: 'LowerLimit',
            width: 180,
            xtype: 'textfield',
            fieldLabel: '电压下限定值',
            allowBlank: false,
            blankText: '不允许为空',
            maskRe: /\d/,
            regex: /\d{5}/,
            regexText: '只能填写5位数字'
        }, {
            name: 'upperLimit',
            id: 'UpperLimit',
            width: 180,
            xtype: 'textfield',
            fieldLabel: '电压上限定值',
            allowBlank: false,
            format: '0',
            blankText: '不允许为空',
            maskRe: /\d/,
            regex: /\d{5}/,
            regexText: '只能填写5位数字'
        },
        {
            xtype: 'textfield',
            fieldLabel: '统计起始日',
            width: 180,
            id: 'CountDate',
            name: 'countDate',
            anchor: '95%'
        }
    ]
};

var basic1 = {
    xtype: 'fieldset',
    title: '基本参数',
    id: 'Basic1',
    //title: 'Addresses',
    autoHeight: true,
    layout: 'column',
    items: [basic11, basic12],
    buttons: [{
            text: '采集',
            id: 'bset1',
            //iconCls: 'icon-save',
            handler: function() {
                var myMask = new Ext.LoadMask(win.getEl(), {msg: "请稍候..."});
                var model = checkboxSel.getSelected().get("model").toUpperCase();
                if ("DT4-2,DT3".indexOf(model) === -1) {
                    Ext.Msg.alert("系统提示", "该型号不支持此操作:" + model);
                    return;
                }
                var submitConfig = {
                    success: function(form, action) {
                        var obj = Ext.decode(action.result.msg);
                        Ext.getCmp('LowerLimit').setValue(obj.XXZ);
                        Ext.getCmp('UpperLimit').setValue(obj.SXZ);
                        param1 = obj.PARAM1;
                        param2 = obj.PARAM2;
                        Ext.Msg.alert("系统提示", "采集成功");
                        myMask.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('提示', action.result.msg);
                        }
                        myMask.hide();
                    },
                    params: {}
                };
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                submitConfig.params.id = checkboxSel.getSelected().get("id");
                submitConfig.params.deviceId = checkboxSel.getSelected().get("deviceId");
                submitConfig.params.model = checkboxSel.getSelected().get("model");
                submitConfig.params.cmd = 'basic1Reader';

                myMask.show();
                Ext.getCmp('input-form').getForm().submit(submitConfig);
            }
        }, {
            text: '设置',
            //iconCls: 'icon-save',
            handler: function() {
                //alert(param2);
                if (typeof param2 === 'undefined' || param2 === null || param2 === "") {
                    Ext.Msg.alert("系统提示", "要先成功读取上下限后才能设置上下限");
                    return;
                }
                var myMask = new Ext.LoadMask(win.getEl(), {msg: "请稍候..."});
                var model = checkboxSel.getSelected().get("model").toUpperCase();
                if ("DT4-2,DT3".indexOf(model) === -1) {
                    Ext.Msg.alert("系统提示", "该型号不支持此操作:" + model);
                    return;
                }

                var submitConfig = {
                    success: function(form, action) {
                        //store.reload();
                        myMask.hide();
                        //win.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('提示', action.result.msg);
                        }
                        myMask.hide();
                    },
                    params: {}
                };
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                submitConfig.params.id = checkboxSel.getSelected().get("id");
                submitConfig.params.deviceId = checkboxSel.getSelected().get("deviceId");
                submitConfig.params.model = checkboxSel.getSelected().get("model");
                submitConfig.params.param1 = param1;
                submitConfig.params.param2 = param2;

                submitConfig.params.cmd = 'basic1Set';
                myMask.show();
                Ext.getCmp('input-form').getForm().submit(submitConfig);
            }
        }, {
            text: '取消',
            handler: function() {
                win.hide();
            }
        }]
};

var basic21 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '波特率',
            name: 'baudRate',
            anchor: '95%'
        }
    ]
};

var basic22 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '心跳',
            name: 'heartRate',
            anchor: '95%'
        }
    ]
};

var basic2 = {
    xtype: 'fieldset',
    title: '通讯参数',
    id: 'Basic2',
    //title: 'Addresses',
    autoHeight: true,
    layout: 'column',
    items: [basic21, basic22],
    buttons: [{
            text: '采集',
            id: 'bset2',
            iconCls: 'icon-save',
            handler: function() {
                var text = Ext.getCmp('bset2').getText();
                if (text === "设置") {
                    Ext.getCmp('bset2').setText('采集');
                } else
                {
                    Ext.getCmp('bset2').setText('设置');
                }
                var submitConfig = {
                    success: function(form, action) {
                        store.reload();
                        win.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('提示', action.result.msg);
                        }
                    },
                    params: {}
                };
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                if (type === 1)
                    submitConfig.params.cmd = 'create';
                else {
                    submitConfig.params.id = checkboxSel.getSelected().get("id");
                    submitConfig.params.cmd = 'update';
                }
                //alert(submitConfig);
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                Ext.getCmp('input-form').getForm().submit(submitConfig);
                //alert('end');
            }
        }, {
            text: '取消',
            handler: function() {
                win.hide();
            }
        }]
};

var basic31 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: 'GPRS用户',
            name: 'GPRSyonghu',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: 'GPRS密码',
            name: 'GPRSmima',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '终端IP',
            name: 'ip',
            anchor: '95%'
        }
    ]
};

var basic32 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '终端端口',
            name: 'port',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '服务器IP',
            name: 'serverIP',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '服务器端口',
            name: 'serverPort',
            anchor: '95%'
        }
    ]
};

var basic3 = {
    xtype: 'fieldset',
    title: 'GPRS参数',
    id: 'Basic3',
    //title: 'Addresses',
    autoHeight: true,
    layout: 'column',
    items: [basic31, basic32],
    buttons: [{
            text: '采集',
            id: 'bset3',
            iconCls: 'icon-save',
            handler: function() {
                var text = Ext.getCmp('bset3').getText();
                if (text === "设置") {
                    Ext.getCmp('bset3').setText('采集');
                } else
                {
                    Ext.getCmp('bset3').setText('设置');
                }
                var submitConfig = {
                    success: function(form, action) {
                        store.reload();
                        win.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('系统提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('系统提示', action.result.msg);
                        }
                    },
                    params: {}
                };
                if (type === 1)
                    submitConfig.params.cmd = 'create';
                else {
                    submitConfig.params.id = checkboxSel.getSelected().get("id");
                    submitConfig.params.cmd = 'update';
                }
                //alert(submitConfig);
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                Ext.getCmp('input-form').getForm().submit(submitConfig);
                //alert('end');
            }
        }, {
            text: '取消',
            handler: function() {
                win.hide();
            }
        }]
};

var basic41 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '终端IP',
            name: 'ip',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '终端端口号',
            name: 'port',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '子掩码',
            name: 'mask',
            anchor: '95%'
        }
    ]
};

var basic42 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '网关IP',
            name: 'gatewayIp',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '服务器IP',
            name: 'serviceIp',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: 'DNS IP',
            name: 'DnsIp',
            anchor: '95%'
        }
    ]
};

var basic4 = {
    xtype: 'fieldset',
    title: '网络参数',
    id: 'Basic4',
    //title: 'Addresses',
    autoHeight: true,
    layout: 'column',
    items: [basic41, basic42],
    buttons: [{
            text: '采集',
            id: 'bset4',
            //iconCls: 'icon-save',
            handler: function() {
                var text = Ext.getCmp('bset4').getText();
                if (text === "设置") {
                    Ext.getCmp('bset4').setText('采集');
                } else
                {
                    Ext.getCmp('bset4').setText('设置');
                }
                var submitConfig = {
                    success: function(form, action) {
                        store.reload();
                        win.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('提示', action.result.msg);
                        }
                    },
                    params: {}
                };
                if (type === 1)
                    submitConfig.params.cmd = 'create';
                else {
                    submitConfig.params.id = checkboxSel.getSelected().get("id");
                    submitConfig.params.cmd = 'update';
                }
                //alert(submitConfig);
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                Ext.getCmp('input-form').getForm().submit(submitConfig);
                //alert('end');
            }
        }, {
            text: '取消',
            handler: function() {
                win.hide();
            }
        }]
};

var basic51 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'button',
            text: '时钟同步',
            name: 'settime',
            anchor: '95%',
            handler: function() {
                var deviceId = checkboxSel.getSelected().get("deviceId");
                var model = checkboxSel.getSelected().get("model");
                var myMask = new Ext.LoadMask(Ext.getBody(), {msg: "请稍候..."});
                myMask.show();
                var token1 = new Date().getTime();
                Ext.Ajax.request({
                    url: '../../../servlet/point/ParamsSet',
                    timeout: 50000,
                    success: function(response, options) {
                        //alert(response.responseText);
                        var obj = Ext.decode(response.responseText);
                        if (obj.success) {
                            Ext.Msg.alert("系统提示", "同步命令发送成功");
                        } else {
                            Ext.Msg.alert("系统提示", obj.msg);
                        }
                        myMask.hide();
                    },
                    failure: function(response, opts) {
                        Ext.Msg.alert('系统提示', '同步失败，清稍候再试 ' + response.status);
                        myMask.hide();
                    },
                    params: {token: token, token1: token1, cmd: "clock", deviceId: deviceId, model: model}
                });
            }
        }
    ]
};

var basic52 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'button',
            text: '远程仪表复位',
            name: 'restart',
            anchor: '95%',
            handler: function() {
                var deviceId = checkboxSel.getSelected().get("deviceId");
                var model = checkboxSel.getSelected().get("model");
                if ("DT4-2".indexOf(model) === -1) {
                    Ext.Msg.alert("系统提示", "该型号不支持远程复位:" + model);
                    return;
                }
                var myMask = new Ext.LoadMask(win.getEl(), {msg: "请稍候..."});
                myMask.show();
                var token1 = new Date().getTime();
                Ext.Ajax.request({
                    url: '../../../servlet/point/ParamsSet',
                    timeout: 50000,
                    success: function(response, options) {
                        var obj = Ext.decode(response.responseText);
                        if (obj.success) {
                            Ext.Msg.alert("系统提示", "复位成功");
                        } else {
                            Ext.Msg.alert("系统提示", obj.msg);
                        }
                        myMask.hide();
                    },
                    failure: function(response, opts) {
                        Ext.Msg.alert('系统提示', '复位失败，清稍候再试 ' + response.status);
                        myMask.hide();
                    },
                    params: {token: token, token1: token1, cmd: "reset", deviceId: deviceId, model: model}
                });
            }
        }
    ]
};

var basic5 = {
    xtype: 'fieldset',
    title: '其他功能',
    id: 'Basic5',
    autoHeight: true,
    layout: 'column',
    items: [basic51, basic52]
};

var clock = {
    xtype: 'fieldset',
    title: '时间参数',
    layout: 'form',
    items: [
        {
            xtype: 'textfield',
            id: 'Time',
            width: 300,
            fieldLabel: '时间(格式：yyMMddhhmmss)',
            labelStyle: 'width:150',
            maskRe: /\d/,
        }
    ],
    buttons: [{
            text: '采集',
            //iconCls: 'icon-save',
            handler: function() {

                var model = checkboxSel.getSelected().get("model").toUpperCase();
                if ("DT4-2,DT3".indexOf(model) === -1) {
                    Ext.Msg.alert("系统提示", "该型号不支持此操作:" + model);
                    return;
                }
                var deviceId = checkboxSel.getSelected().get("deviceId");
                var myMask = new Ext.LoadMask(win.getEl(), {msg: "请稍候..."});
                var token1 = new Date().getTime();
                myMask.show();
                Ext.Ajax.request({
                    url: '../../../servlet/point/ParamsSet',
                    timeout: 50000,
                    success: function(response, options) {
                        var obj = Ext.decode(response.responseText);
                        //alert(response.responseText);
                        //var msgObj = Ext.decode(obj.msg);
                        //alert(msgObj.TIME);
                        if (obj.success) {
                            Ext.getCmp('Time').setValue(msgObj.TIME);
                            Ext.Msg.alert("系统提示", "采集成功");
                        } else {
                            Ext.Msg.alert("系统提示", obj.msg);
                        }
                        myMask.hide();
                    },
                    failure: function(response, opts) {
                        Ext.Msg.alert('系统提示', '时间采集失败，清稍候再试 ' + response.status);
                        myMask.hide();
                    },
                    params: {token: token, token1: token1, cmd: "clockRead", deviceId: deviceId, model: model}
                });
            }
        }, {
            text: '设置',
            //iconCls: 'icon-save',
            handler: function() {

                var model = checkboxSel.getSelected().get("model").toUpperCase();
                if ("DT4-2,DT3".indexOf(model) === -1) {
                    Ext.Msg.alert("系统提示", "该型号不支持此操作:" + model);
                    return;
                }
                var deviceId = checkboxSel.getSelected().get("deviceId");
                var myMask = new Ext.LoadMask(win.getEl(), {msg: "请稍候..."});
                var time = Ext.getCmp('Time').getValue();
                myMask.show();
                var token1 = new Date().getTime();
                Ext.Ajax.request({
                    url: '../../../servlet/point/ParamsSet',
                    timeout: 50000,
                    success: function(response, options) {
                        var obj = Ext.decode(response.responseText);
                        if (obj.success) {
                            Ext.Msg.alert("系统提示", "命令发送成功");
                        } else {
                            Ext.Msg.alert("系统提示", obj.msg);
                        }
                        myMask.hide();
                    },
                    failure: function(response, opts) {
                        Ext.Msg.alert('系统提示', '时间设置失败，清稍候再试 ' + response.status);
                        myMask.hide();
                    },
                    params: {token: token, token1: token1, cmd: "clockSet", deviceId: deviceId, model: model, time: time}
                });
            }
        }, {
            text: '取消',
            handler: function() {
                win.hide();
            }
        }]
};
var inputForm = new Ext.FormPanel(
        {
            xtype: 'form',
            id: 'input-form',
            bodyStyle: 'padding:15px;background:transparent',
            frame: true,
            //width:650,
            border: false,
            url: paramsSetServlet,
            items: [
                basic1, /*basic2, basic3, basic4,*/ clock, basic5
            ]
        }
);
var win = new Ext.Window({
    layout: 'form',
    width: 650,
    autoHeight: true,
    modal: true,
    closeAction: 'hide',
    items: [inputForm]
});
var type = 1; //判断打开窗口是进行更新，还是新建。1-新建；2-修改
var updated = false;


function getIds(rs) {
    var jsonData = "";
    var jsonDataDevices = "";
    for (var i = 0, len = rs.length; i < len; i++) {
        var ss = rs[i].get("id"); //这里为Grid数据源的Id列
        var ssDevices = rs[i].get("deviceId");
        if (i === 0) {
            jsonData = jsonData + ss;
            jsonDataDevices = jsonDataDevices + ssDevices;
        } else {
            jsonData = jsonData + "," + ss;
            jsonDataDevices = jsonDataDevices + "," + ssDevices;
        }
    }
    return {pointIds: jsonData, deviceIds: jsonDataDevices};
}
function getPointNames(rs, n) {
    var jsonData = "";
    for (var i = 0, len = rs.length; i < len; i++) {
        var ss = rs[i].get(n);
        if (i === 0) {
            jsonData = jsonData + ss;
        } else {
            jsonData = jsonData + "," + ss;
        }
    }
    return jsonData;
}

function setDeviceParams() {
    if (checkboxSel.getSelections().length === 0) {
        Ext.Msg.alert("系统提示", "您还没有选择装置");
    } else if (checkboxSel.getSelections().length > 1) {
        Ext.Msg.alert("系统提示", "您选择了多项，一次只能选择一项");
    } else {
        var r = checkboxSel.getSelected();
        var deviceId = r.get('deviceId');
        if (deviceId === 0) {  //新增
            Ext.Msg.alert("系统提示", "该监测点还没要设置装置");
        } else {   //修改
            type = 1;
            win.setTitle('远程参数设置');
            Ext.getCmp('input-form').getForm().loadRecord(checkboxSel.getSelected());
            /*var ctn = r.get('commTypeName');
             switch (ctn)
             {
             case 'GPRS':
             Ext.getCmp('Basic4').setVisible(false);
             Ext.getCmp('Basic3').setVisible(true);
             break;
             case '有线网络':
             Ext.getCmp('Basic3').setVisible(false);
             Ext.getCmp('Basic4').setVisible(true);
             break;
             default :
             Ext.getCmp('Basic4').setVisible(false);
             Ext.getCmp('Basic3').setVisible(false);
             break;
             }*/
            param1 = "";
            param2 = "";
            win.show();
        }
    }
}

var batchBasic11 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '行政区域码',
            name: 'adminAreaCode',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '组编码',
            name: 'zbm',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '波特率',
            name: 'baudRate',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '心跳',
            name: 'heartRate',
            anchor: '95%'
        }
    ]
};
var batchBasic12 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            xtype: 'textfield',
            fieldLabel: '统计起始日',
            name: 'tjqsr',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '服务器IP',
            name: 'serviceIp',
            anchor: '95%'
        },
        {
            xtype: 'textfield',
            fieldLabel: '服务器端口',
            name: 'servicePort',
            anchor: '95%'
        }
    ]
};
var batchBasic1 = {
    xtype: 'fieldset',
    title: '批量设置参数',
    id: 'batchBasic1',
    //title: 'Addresses',
    autoHeight: true,
    layout: 'column',
    items: [batchBasic11, batchBasic12]
};
var batchBasic2 = {
    xtype: 'fieldset',
    title: '所选监测点名称',
    id: 'batchBasic2',
    //title: 'Addresses',
    autoHeight: true,
    layout: 'column',
    items: [
        {
            width: '100%',
            id: 'chooseName',
            height: 100,
            xtype: 'textarea',
            fieldLabel: '文本域'
        }
    ]
};

var batchForm = new Ext.FormPanel(
        {
            xtype: 'form',
            id: 'batchForm-form',
            bodyStyle: 'padding:15px;background:transparent',
            frame: true,
            //width:650,
            border: false,
            url: 'saveServlet',
            items: [
                batchBasic2, batchBasic1
            ],
            buttons: [{
                    text: '设置',
                    iconCls: 'icon-save',
                    handler: function() {
                        var submitConfig = {
                            success: function(form, action) {
                                store.reload();
                                win.hide();
                            },
                            failure: function(form, action) {
                                switch (action.failureType) {
                                    case Ext.form.Action.CONNECT_FAILURE:
                                        Ext.Msg.alert('提示', '网络连接失败');
                                        break;
                                    case Ext.form.Action.SERVER_INVALID:
                                        Ext.Msg.alert('提示', action.result.msg);
                                }
                            },
                            params: {}
                        };
                        if (type === 1)
                            submitConfig.params.cmd = 'create';
                        else {
                            submitConfig.params.id = checkboxSel.getSelected().get("id");
                            submitConfig.params.cmd = 'update';
                        }
                        //alert(submitConfig);
                        var token1 = new Date().getTime();
                        submitConfig.params.token = token;
                        submitConfig.params.token1 = token1;
                        Ext.getCmp('input-form').getForm().submit(submitConfig);
                        //alert('end');
                    }
                }, {
                    text: '取消',
                    handler: function() {
                        winBatch.hide();
                    }
                }]
        }
);
var winBatch = new Ext.Window({
    layout: 'form',
    width: 650,
    autoHeight: true,
    modal: true,
    closeAction: 'hide',
    items: [batchForm]
});

function setDeviceParamsBatch() {
    if (checkboxSel.getSelections().length === 0) {
        Ext.Msg.alert("系统提示", "您还没有选择装置");
    } else {
        var r = checkboxSel.getSelected();
        var deviceId = r.get('deviceId');
        if (deviceId === 0) {  //新增
            Ext.Msg.alert("系统提示", "该监测点还没要设置装置");
        } else {   //修改
            winBatch.setTitle('批量参数设置');
            //Ext.getCmp('input-form').getForm().loadRecord(checkboxSel.getSelected());chooseName
            var pointNames = getPointNames(checkboxSel.getSelections(), 'name');
            Ext.getCmp('chooseName').setValue(pointNames);
            winBatch.show();
        }
    }
}

function recallDeviceParams() {
    if (checkboxSel.getSelections().length === 0) {
        Ext.Msg.alert("系统提示", "您还没有选择装置");
    } else if (checkboxSel.getSelections().length > 1) {
        Ext.Msg.alert("系统提示", "您选择了多项，一次只能选择一项");
    } else {
        var r = checkboxSel.getSelected();
        var deviceId = r.get('deviceId');
        if (deviceId === 0) {  //新增
            Ext.Msg.alert("系统提示", "该监测点还没要设置装置");
        } else {   //修改
            if (win === null) {
                win = new Ext.Window({
                    layout: 'form',
                    width: 340,
                    autoHeight: true,
                    closeAction: 'hide',
                    items: [inputForm]
                });
            }
            ;
            type = 2;
            win.setTitle('参数召回');
            Ext.getCmp('input-form').getForm().reset();
            var ctn = r.get('commTypeName');
            switch (ctn)
            {
                case 'GPRS':
                    Ext.getCmp('Basic4').setVisible(false);
                    Ext.getCmp('Basic3').setVisible(true);
                    break;
                case '有线网络':
                    Ext.getCmp('Basic3').setVisible(false);
                    Ext.getCmp('Basic4').setVisible(true);
                    break;
                default :
                    Ext.getCmp('Basic4').setVisible(false);
                    Ext.getCmp('Basic3').setVisible(false);
                    break;
            }
            win.show();
        }
    }
}

var basicData11 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            fieldLabel: '监测点名称',
            name: 'name',
            readOnly: true,
            anchor: '95%'
        },
        {
            fieldLabel: '行政区域码',
            name: 'adminAreaCode',
            readOnly: true,
            anchor: '95%'
        },
        {
            fieldLabel: '组编码',
            name: 'zbm',
            readOnly: true,
            anchor: '95%'
        },
        {
            fieldLabel: '终端地址',
            name: 'terminalNo',
            readOnly: true,
            anchor: '95%'
        }
    ]
};

var basicData12 = {columnWidth: .5,
    layout: 'form',
    //labelAlign: 'top',
    defaultType: 'textfield',
    items: [
        {
            id: 'voltageLeveltx',
            name: 'voltageLevelName',
            width: 180,
            xtype: 'textfield',
            fieldLabel: '电压等级',
            readOnly: true,
            allowBlank: false
        },
        {
            name: 'lowerLimit',
            width: 180,
            xtype: 'textfield',
            fieldLabel: '电压下限定值',
            readOnly: true,
            allowBlank: false
        }, {
            name: 'upperLimit',
            width: 180,
            xtype: 'textfield',
            fieldLabel: '电压上限定值',
            readOnly: true,
            allowBlank: false
        },
        {
            fieldLabel: '统计起始日',
            name: 'countDate',
            readOnly: true,
            anchor: '95%'
        }
    ]
};

var basicData1 = {
    xtype: 'fieldset',
    title: '监测点信息',
    id: 'BasicData1',
    autoHeight: true,
    layout: 'column',
    items: [basicData11, basicData12]
};



var basicData2 = {
    xtype: 'fieldset',
    title: '日数据',
    autoHeight: true,
    layout: 'column',
    items: [
        {
            xtype: 'datefield',
            id: 'RDate',
            format: 'm月d日',
            anchor: '95%',
            value: now.add(Date.DATE, -1)
        },
        {
            width: '100%',
            id: 'RsjData',
            height: 60,
            xtype: 'textarea',
            fieldLabel: '文本域',
            readOnly: true,
            anchor: '95%'
        }
    ],
    buttons: [{
            text: '采集',
            iconCls: '',
            handler: function() {
                respRsjObj = null;
                Ext.getCmp('RsjData').setValue('');
                var myMask = new Ext.LoadMask(Ext.getCmp('WinData').getEl(), {msg: "请稍候,正在取数据..."});
                myMask.show();
                var submitConfig = {
                    success: function(form, action) {

                        respRsjObj = Ext.decode(action.result.msg);
                        var vl = Ext.getCmp('voltageLeveltx').getValue();
                        var factor = voltageLevel2Value(vl);
                        respRsjObj.ZDZ = respRsjObj.ZDZ * factor;
                        respRsjObj.ZXZ = respRsjObj.ZXZ * factor;
                        respRsjObj.PJZ = respRsjObj.PJZ * factor;
                        var resultStr = toReadableStr(respRsjObj);

                        Ext.getCmp('RsjData').setValue(resultStr);
                        myMask.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('提示', action.result.msg);
                        }
                        myMask.hide();
                    },
                    params: {}
                };
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                submitConfig.params.cmd = 'rsj';
                submitConfig.params.deviceId = checkboxSel.getSelected().get("deviceId");
                submitConfig.params.date = Ext.getCmp('RDate').getValue().format('md');
                Ext.getCmp('InputFormData').getForm().submit(submitConfig);
            }
        }, {
            text: '保存',
            handler: function() {

                var respStr = Ext.getCmp('RsjData').getValue();
                if (respRsjObj === null || respStr === null || respStr.trim() == '') {
                    Ext.Msg.alert('系统提示', '请先采集成功后再保存');
                    return;
                }

                Ext.MessageBox.confirm('系统提示', '确实要保存记录吗?', function(btn) {
                    if (btn === 'yes') {
                        var deviceId = checkboxSel.getSelected().get("deviceId");
                        var id = checkboxSel.getSelected().get("id");
                        var vl = checkboxSel.getSelected().get("voltageLevelName");  //电压等级
                        var year = respRsjObj.YEAR;
                        var month = respRsjObj.Month;
                        var date = respRsjObj.Date;

                        var myMask = new Ext.LoadMask(Ext.getBody(), {msg: "请稍候..."});
                        myMask.show();
                        var token1 = new Date().getTime();
                        Ext.Ajax.request({
                            url: '../../../servlet/data/RsjSave',
                            timeout: 50000,
                            success: function(response, options) {
                                //alert(response.responseText);
                                var obj = Ext.decode(response.responseText);
                                if (obj.success) {
                                    Ext.Msg.alert("系统提示", "保存成功");
                                } else {
                                    Ext.Msg.alert("系统提示", obj.msg);
                                }
                                myMask.hide();
                            },
                            failure: function(response, opts) {
                                Ext.Msg.alert('系统提示', '保存失败，清稍候再试 ' + response.status);
                                myMask.hide();
                            },
                            params: {token: token, token1: token1, cmd: "recallSave", pointId: id
                                , deviceId: deviceId, voltageLevelName: vl, data: respStr
                                , dataYear: year, dataMonth: month, dataDay: date, totalRunMin: respRsjObj.ZYXS
                                , aboveUpperLimitMin: respRsjObj.CSXS, underLowerLimitMin: respRsjObj.CXXS
                                , maxVoltage: respRsjObj.ZDZ, maxVoltageTime: respRsjObj.ZDZS.substring(4, 6) + ":" + respRsjObj.ZDZS.substring(6, 8) + ':00',
                                minVoltage: respRsjObj.ZXZ, minVoltageTime: respRsjObj.ZXZS.substring(4, 6) + ":" + respRsjObj.ZXZS.substring(6, 8) + ':00',
                                avgVoltage: respRsjObj.PJZ}
                        });
                    }
                });


            }
        }]
};

var basicData3 = {
    xtype: 'fieldset',
    title: '月数据',
    autoHeight: true,
    layout: 'column',
    items: [
        {
            xtype: 'monthcombo',
            id: 'Month',
            value: thisMonth
        },
        {
            width: '100%',
            id: 'YsjData',
            height: 60,
            xtype: 'textarea',
            fieldLabel: '文本域',
            readOnly: true,
            disable: true,
            anchor: '95%'
        }
    ],
    buttons: [{
            text: '采集',
            iconCls: '',
            handler: function() {
                respYsjObj = null;
                Ext.getCmp('YsjData').setValue('');
                var myMask = new Ext.LoadMask(Ext.getCmp('WinData').getEl(), {msg: "请稍候,正在取数据..."});
                myMask.show();
                var submitConfig = {
                    success: function(form, action) {

                        respYsjObj = Ext.decode(action.result.msg);
                        
                        var vl = Ext.getCmp('voltageLeveltx').getValue();
                        var factor = voltageLevel2Value(vl);  //乘以电压等级
                        respYsjObj.ZDZ = respYsjObj.ZDZ * factor;
                        respYsjObj.ZXZ = respYsjObj.ZXZ * factor;
                        respYsjObj.PJZ = respYsjObj.PJZ * factor;
                        var resultStr = toReadableStr(respYsjObj, factor);
                        Ext.getCmp('YsjData').setValue(resultStr);
                        myMask.hide();
                    },
                    failure: function(form, action) {
                        switch (action.failureType) {
                            case Ext.form.Action.CONNECT_FAILURE:
                                Ext.Msg.alert('提示', '网络连接失败');
                                break;
                            case Ext.form.Action.SERVER_INVALID:
                                Ext.Msg.alert('提示', action.result.msg);
                        }
                        myMask.hide();
                    },
                    params: {}
                };
                var token1 = new Date().getTime();
                submitConfig.params.token = token;
                submitConfig.params.token1 = token1;
                submitConfig.params.cmd = 'ysj';
                submitConfig.params.deviceId = checkboxSel.getSelected().get("deviceId");
                //submitConfig.params.date = Ext.getCmp('Month').getValue()
                Ext.getCmp('InputFormData').getForm().submit(submitConfig);
            }
        }, {
            text: '保存',
            handler: function() {
                var respStr = Ext.getCmp('YsjData').getValue();
                if (respYsjObj === null || respStr === null || respStr.trim() == '') {
                    Ext.Msg.alert('系统提示', '请先采集成功后再保存');
                    return;
                }

                Ext.MessageBox.confirm('系统提示', '确实要保存记录吗?', function(btn) {
                    if (btn === 'yes') {
                        var deviceId = checkboxSel.getSelected().get("deviceId");
                        var id = checkboxSel.getSelected().get("id");
                        var vl = checkboxSel.getSelected().get("voltageLevelName");  //电压等级
                        var year = respYsjObj.YEAR;
                        var month = respYsjObj.Month;
                        

                        var myMask = new Ext.LoadMask(Ext.getBody(), {msg: "请稍候..."});
                        myMask.show();
                        var token1 = new Date().getTime();
                        Ext.Ajax.request({
                            url: '../../../servlet/data/YsjSave',
                            timeout: 50000,
                            success: function(response, options) {
                                //alert(response.responseText);
                                var obj = Ext.decode(response.responseText);
                                if (obj.success) {
                                    Ext.Msg.alert("系统提示", "保存成功");
                                } else {
                                    Ext.Msg.alert("系统提示", obj.msg);
                                }
                                myMask.hide();
                            },
                            failure: function(response, opts) {
                                Ext.Msg.alert('系统提示', '保存失败，清稍候再试 ' + response.status);
                                myMask.hide();
                            },
                            params: {token: token, token1: token1, cmd: "recallSave", pointId: id
                                , deviceId: deviceId, voltageLevelName: vl, data: respStr
                                , dataYear: year, dataMonth: month, totalRunMin: respYsjObj.ZYXS
                                , aboveUpperLimitMin: respYsjObj.CSXS, underLowerLimitMin: respYsjObj.CXXS
                                , maxVoltage: respYsjObj.ZDZ, maxVoltageTime: toTimestamp(year,respYsjObj.ZDZS),
                                minVoltage: respYsjObj.ZXZ, minVoltageTime: toTimestamp(year,respYsjObj.ZXZS),
                                avgVoltage: respYsjObj.PJZ}
                        });
                    }
                });

            }
        }]
};
var inputFormData = new Ext.FormPanel(
        {
            xtype: 'form',
            id: 'InputFormData',
            bodyStyle: 'padding:15px;background:transparent',
            frame: true,
            border: false,
            url: paramsSetServlet,
            items: [
                basicData1, basicData2, basicData3
            ]
        }
);

var winData = new Ext.Window({
    layout: 'form',
    id: 'WinData',
    width: 640,
    autoHeight: true,
    closeAction: 'hide',
    modal: true,
    items: [inputFormData]
});

function recallData() {
    respRsjObj = null;
    respYsjObj = null;
    if (checkboxSel.getSelections().length === 0) {
        Ext.Msg.alert("系统提示", "您还没有选择装置");
    } else if (checkboxSel.getSelections().length > 1) {
        Ext.Msg.alert("系统提示", "您选择了多项，一次只能选择一项");
    } else {
        var r = checkboxSel.getSelected();
        var deviceId = r.get('deviceId');
        if (deviceId === 0) {  //新增
            Ext.Msg.alert("系统提示", "该监测点还没要设置装置");
        } else {   //修改
            type = 2;
            winData.setTitle('数据召回');
            Ext.getCmp('InputFormData').getForm().reset();
            Ext.getCmp('InputFormData').getForm().loadRecord(checkboxSel.getSelected());
            //alert(thisMonth);
            Ext.getCmp('RDate').setValue(now.add(Date.DATE, -1));
            Ext.getCmp('Month').setValue(thisMonth);
            winData.show();
        }
    }
}

var checkboxSel = new Ext.grid.CheckboxSelectionModel();
var store;
function buildWindow() {
    store = new Ext.data.JsonStore({
        url: loadServlet,
        root: 'data',
        idProperty: 'id',
        totalProperty: 'count',
        fields: fieldName
        , baseParams: {start: 0, limit: _pageSize, cmd: 'param'}
        , autoLoad: true
    });


    var grid = new Ext.grid.GridPanel({
        title: _title,
        store: store,
        sm: checkboxSel,
        autoExpandColumn: fieldLabel[12],
        columns: [
            checkboxSel,
            {header: fieldLabel[0], sortable: true, dataIndex: fieldName[0], hidden: true},
            {header: '监测点编码', width: 100, sortable: true, dataIndex: 'code'},
            {header: '监测点名称', width: 100, sortable: true, dataIndex: 'name'},
            {header: '监测点类型', width: 100, sortable: true, dataIndex: 'pointType'},
            {header: '电网类型', width: 100, sortable: true, dataIndex: 'pointType2'},
            {header: '电压等级', width: 100, sortable: true, dataIndex: 'voltageLevelName', align: 'right'},
            {header: '电压下限', width: 100, sortable: true, dataIndex: 'lowerLimit', xtype: 'numbercolumn', format: '0.00', align: 'right'},
            {header: '电压上限', width: 100, sortable: true, dataIndex: 'upperLimit', xtype: 'numbercolumn', format: '0.00', align: 'right'},
            {header: '倍率', width: 100, sortable: true, dataIndex: 'ratio'},
            {header: '统计起始日', width: 120, sortable: true, dataIndex: 'countDate'},
            {header: 'THD限值', width: 100, sortable: true, dataIndex: 'thdLimit'},
            {header: '通讯方式', width: 80, sortable: true, dataIndex: 'commTypeName', hidden: false},
            {header: '波特率', width: 100, sortable: true, dataIndex: 'baudRate'},
            {header: '心跳', width: 100, sortable: true, dataIndex: 'heartRate'},
            {header: 'GPRS用户', width: 100, sortable: true, dataIndex: 'GPRSyonghu'},
            {header: 'GPRS密码', width: 100, sortable: true, dataIndex: 'GPRSmima'},
            {header: '终端IP', width: 100, sortable: true, dataIndex: 'ip'},
            {header: '终端端口', width: 100, sortable: true, dataIndex: 'port'},
            {header: 'APN', width: 100, sortable: true, dataIndex: 'Apn'},
            {header: 'DNSIP', width: 100, sortable: true, dataIndex: 'DnsIp'},
            {header: '服务器IP', width: 100, sortable: true, dataIndex: 'serviceIp'},
            {header: '服务器端口', width: 100, sortable: true, dataIndex: 'servicePort'},
            {header: '子掩码', width: 100, sortable: true, dataIndex: 'mask'},
            {header: '网关IP', width: 100, sortable: true, dataIndex: 'gatewayIp'},
            //{header: '用户名称', width: 120, sortable: true, dataIndex: 'userName'},
            //{header: '公变名称', width: 120, sortable: true, dataIndex: 'publicName'},
            {header: '终端地址', width: 100, sortable: true, dataIndex: 'terminalNo'},
            {header: '行政区域码', width: 100, sortable: true, dataIndex: 'adminAreaCode'},
            {header: '组编码', width: 100, sortable: true, dataIndex: 'zbm'},
            {header: '通信卡号', width: 100, sortable: true, dataIndex: 'mobileNo'},
            {header: '唯一码', width: 100, sortable: true, dataIndex: 'uniqueCode'},
            {header: '通道', width: 100, sortable: true, dataIndex: 'channel'},
            {header: '型号', width: 100, sortable: true, dataIndex: 'model'},
            {header: '生产厂家', width: 100, sortable: true, dataIndex: 'manufactoryName'},
            {header: '生产日期', width: 120, sortable: true, dataIndex: 'produceTime', xtype: 'datecolumn', format: 'Y-m-d'},
            {header: '校验日期', width: 120, sortable: true, dataIndex: 'checkTime', xtype: 'datecolumn', format: 'Y-m-d'},
            {header: '启用/停用', width: 80, sortable: true, dataIndex: 'startStatusCh'},
            {header: '备注', id: fieldLabel[12], width: 80, sortable: true, dataIndex: 'note'}
        ],
        loadMask: true,
        tbar: new Ext.Toolbar([
            {text: '远程参数设置', iconCls: 'icon-add', handler: setDeviceParams},
            {text: '批量参数设置', iconCls: 'icon-edit', handler: setDeviceParamsBatch},
            {text: '参数召回', iconCls: 'icon-delete', handler: recallDeviceParams, hidden: true},
            {text: '数据读取', iconCls: '', handler: recallData}
        ]),
        bbar: new Ext.PagingToolbar({
            pageSize: _pageSize,
            store: store,
            displayInfo: true,
            displayMsg: '显示记录：{0} - {1}   总记录：{2}',
            emptyMsg: "目前没有" + theme + '信息'
        }),
        listeners: {
            'render': function() {
                tbarPoint.render(this.tbar);
            }
        }
    });
    //grid.el.center();
    //store.load({params: {start: 0, limit: _pageSize}});

    var applicationUI = new Ext.Viewport({
        layout: "fit",
        items: [
            grid
        ]
    });
}
Ext.onReady(buildWindow);
